// const storageAction = {
//     get(key) {
//       return  localStorage.getItem(key)
//     },
//      set(key,data) {
//         localStorage.setItem(key,JSON.stringify(data))
//     },
//      remove(key) {
//         localStorage.removeItem(key)
//     },
//      clear() {
//         localStorage.clear()
//     }
// }
import { storageKeys } from '../config/config'
class StorageAction {
  key = '';
  constructor(key) {
    this.key = key
  }
  get() {
    return localStorage.getItem(this.key)
  }
  set(data) {
    localStorage.setItem(this.key, JSON.stringify(data))
  }
  remove() {
    localStorage.removeItem(this.key)
  }
  clear() {
    localStorage.clear()
  }
}

const storages = {}

function createStorageFactoryByStorageKeys(keys) {
  keys.forEach(aa => {
    storages[aa] = new StorageAction(aa.toLocaleUpperCase())
  })
}

(() => createStorageFactoryByStorageKeys(storageKeys))()

export { storages }
